----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 11102 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 1024
SPELL.m_sName = "Triple Shot"
SPELL.m_sToolTip =	[[Bombard the target with
					  projectiles, dealing
					  moderate damage.]]
SPELL.m_sIcon = "devin/blackbetty/spells/ranger/frostbarrage.png"
SPELL.m_iCoolDown = 6
SPELL.m_iManaCost = 0
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_RANGEDAMAGE

---------------------------------------------------------------------------------------

function SPELL:Cast( pl, target )

	local weapon = pl:GetWeapon("weapon_all")
	local range = self.m_iRange
	
	print("Casted "..self.m_sName.."!")
		
	if(target && target:IsValid() && target != pl) then
		timer.Simple(.6, function()
			pl:SetNWBool("Casting", false)
			pl:SetNWBool("Casted", false)
			pl.DoingCast = false
		end)
		net.Start( "SendPlayerCast" )
		local SendTable = {.6, self.m_sName, Color(215, 100, 0, 255)}
		net.WriteTable(SendTable)
		net.Send(pl)
		pl.DoingCast = true
		pl.CastWhileMoving = true
		timer.Create(""..pl:EntIndex().."frostbarrage", 0.2, 3, function()
			pl:EmitSound("devin/blackbetty/weapons/bow/BowRelease01.wav", 80, math.random(110, 130))
			pl:DoAnimationEvent(ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW)
			local myhitdelay = ((pl:GetPos() - target:GetPos()):Length()/2400)
			ParticleEffect( "pummel_hit", pl:GetPos() + (pl:GetAngles():Forward()*48) + Vector(0, 0, 45) + (pl:GetAngles():Right()*16), Angle(0,0,0), pl )
			LaunchProjectile(pl, target, 0, "pummel_hit", "", "autoshot", "devin/blackbetty/weapons/bow/BowArrowInFlightLoop.wav", myhitdelay+0.15, 1800, "models/crossbow_bolt.mdl")
			timer.Simple(myhitdelay, function()
				self:DealDamage(weapon.MinWeaponDamage*0.6, weapon.MaxWeaponDamage*0.6, pl, target, DMG_GENERIC)
				target:EmitSound("devin/blackbetty/weapons/bow/ArrowHit0"..math.random(1,3)..".wav", 100, 100+math.random(-10,10))
				ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 45), Angle(0,0,0), target )
				end)
			end)
		else
			pl:SetNWBool("Casting", false)
			pl:SetNWBool("Casted", false)
			pl.DoingCast = false
			return true
	end
end




